class PartStyle < ActiveRecord::Base
	has_many :parts, dependent: :destroy
	has_many :order_maintain_parts
	has_many :part_purchase_details
	has_many :part_stockin_details
	has_many :part_stockout_details
	has_many :part_salse_details
	has_many :order_beauty_parts


    accepts_nested_attributes_for :parts

	after_create :gen_code

	def gen_code
	  code = rand(100000).to_s.rjust(6, "0")
	  update_attributes(code: code)
	end
end
